from v3.Spider import Spider
from v3.RequestItem import RequestItem
from v3.Pipeline import DefaultPipeline
from v3.SockPuppet import SockPuppet
from v3.headers_list import headers_list
from v3.SinaResultProcessor import SinaCommentResultProcessor


if __name__ == '__main__':
    request_items = []
    sock_puppet = SockPuppet.create()
    sock_puppet.set_list(headers_list)
    for i in range(61, 50, -1):
        request_items.append(RequestItem(url='https://m.weibo.cn/api/comments/show',
                                         params={'id': '4620209346582917', 'page': str(i)}, timeout=2))

    spider = Spider(request_items=request_items,
                    pipeline=DefaultPipeline(),
                    result_processor=SinaCommentResultProcessor(),
                    sock_puppet=sock_puppet,
                    thread_num=3,
                    sleep_time=1)
    spider.run()